Skip to main content

Server-Client Example

BridgeNet.Start should always be called first with the table, before creating bridges.

Server

local ReplicatedStorage = game:GetService("ReplicatedStorage")

local BridgeNet = require(ReplicatedStorage.Packages.BridgeNet)

BridgeNet.Start({})

local Remote = BridgeNet.CreateBridge("Remote")

while true do
Remote:FireAll("Hello, ", "world!") -- Fires to everyone
Remote:FireTo(game.Players.Someone, "Hello, ", "someone!") -- Fires to a specific player
task.wait(1)
end

Client

local ReplicatedStorage = game:GetService("ReplicatedStorage")

local BridgeNet = require(ReplicatedStorage.Packages.BridgeNet)

BridgeNet.Start({})

local Remote = BridgeNet.CreateBridge("Remote")

Remote:Connect(function(stringA, stringB)
print(stringA .. stringB) -- Prints "Hello, someone!"
end)